<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <ytata:bbsview listname="b" id="$_GET['id']"/>
    <title>{:SEO('bbs-view','title',array('BBS_TITLE'=>$b['content']))}</title>
    <meta name="keywords" content="{:SEO('bbs-view','keywords',array('BBS_TITLE'=>$b['content']))}">
    <meta name="description" content="{:SEO('bbs-view','description',array('BBS_TITLE'=>$b['content']))}">
    <link href="__ROOT__/{:C('YTATA_TPL_DIR')}/public/css/bbs.css" rel="stylesheet" type="text/css">
    <include file="public:header"/>
    <div class="bshow">
        <div class="cmain">
          <div class="box1">

                <div class="titlebtn">
                 

                    <div class="follow">
                        <eq name="Think.session.ytata.uid" value=""><!--未登录 -->

                            <div class="fbtns J_follow" data-id="{$b.id}">关注</div>
                            <div class="followtxt"><strong class="J_follow_count">{$b.follow_count}</strong>关注</div>
                            <div class="fbtns w J_favorites" data-id="{$b.id}">收藏</div>
                            <div class="followtxt"><strong class="J_favorites_count">{$b.favorites_count}</strong>收藏
                            </div>
                            <div class="clear"></div>


                            <else/><!--已登录 -->

                            <eq name="b.is_follow" value="1">
                                <div class="fbtns J_follow" data-id="{$b.id}">已关注</div>
                                <else/>
                                <div class="fbtns J_follow" data-id="{$b.id}">关注</div>
                            </eq>
                            <div class="followtxt"><strong class="J_follow_count">{$b.follow_count}</strong>关注</div>
                          
                            <eq name="b.is_favorites" value="1">
                                <div class="fbtns w J_favorites" data-id="{$b.id}">已收藏</div>
                                <else/>
                                <div class="fbtns w J_favorites" data-id="{$b.id}">收藏</div>
                            </eq>
                            <div class="followtxt"><strong class="J_favorites_count">{$b.favorites_count}</strong>收藏
                            </div>
                            <div class="clear"></div>


                        </eq>

                    </div>
					
                    <div class="userinfo link_gray3">
                        <div class="avatar"><img src="{$b.adduser.avatar}" border="0"></div>
                        <div class="info">
						<a href="{$b.adduser.user_url}">{$b.adduser.nickname}</a> <span>|</span>{$b.addtimestr}<span>|</span> 浏览<u>{$b.click}</u>次

							  <notempty name="b.tags">
							  <span>|</span><strong class="tag">
							  </notempty>
							<volist name="b.tags" id="vo"><a href="{$vo.tagurl}">{$vo.tag}</a></volist>
							<notempty name="b.tags">
							  </strong>
							  </notempty>
                        </div>
						<div class="clear"></div>
                  </div>
				  
				  

                </div>

        
 
                <div class="txt">{$b.content}</div>
				
				
				
				
							 
				 <!--自己发布并且没有关注过公众号提示关注公众号--->
				<if condition="C('YTATA_WEIXIN_APIOPEN')=='1' AND $b['uid']==$Think.session.ytata.uid AND $b['adduser']['openid']==''">
			  <div class="wxcode">
			    		<div class="code"><img src="{:C('YTATA_WEIXIN_QRCODE')}" border="0"></div>
				<div class="codetxt">
								想要第一时间收到答案吗?<br>
						扫描左侧二维码,关注“{:C('YTATA_WEIXIN_MPNAME')}”微信公众号即可！
						<div class="wxtip">亲！关注后有人回复你的微信将会收到提醒哦！</div>
			    </div>
						<div class="clear"></div>
			  </div>  
			   </if>        
			   
							
				
                 <div class="zan"><span id="J_bbs_praise" data-id="{$b.id}">{$b['count_praise'] ? $b['count_praise'] : '点赞'}</span></div>
                 <!-- 图片-->
                <notempty name="b.imgs">
                    <div class="qimgbox">
                        <volist name="b.imgs" id="v">
                            <div class="imgli" style="height: auto;">
                                <a href="javascript:open_img('q-img{$v.id}')">
                                    <img src="{$v.imgurl}" border="0">
                                </a>
                            </div>
                            <div id="q-img{$v.id}" style="display: none;" ><img src="{$v.imgurl}" alt=""></div>
                        </volist>
                        <div class="clear"></div>
                    </div>
                </notempty>
             
                    <!--显示主题回复提交框 -->
                    <div class="suppinputbox">
                  
                        <textarea name="content" cols="" rows="" class="input J_supp_input" placeholder="说说你的看法"></textarea>
                        <div class="askedbtn">
                            <input type="button" class="btn_green btn_inline btn_border J_supp_btn" data-id="{$b.id}" value="发表">
                        </div>
                    </div>
					
                    
          <ytata:bbsreply listname="bbsreply" bid="$b['id']" />
            <empty name="bbsreply.list">
              <div class="infoempty"> 暂时还没木有人回帖，快抢占沙发吧～～</div>
            </empty>
            <volist name="bbsreply.list" id="bbsreply">
              <div class="reply">
                <div class="avatar"><img src="{$bbsreply.adduser.avatar}">
                </div>
                
                <div class="txts">
                  <div class="floor">{$bbsreply.floor}楼</div>
                  <eq name="bbsreply.praise" value="0">
                    <div class="zan J_bbsreply_praise" data-rid="{$bbsreply.id}">点赞</div>
                    <else/>
                    <div class="zan J_bbsreply_praise" data-rid="{$bbsreply.id}">{$bbsreply.praise}</div>
                  </eq>
                  <div class="usertxt link_gray3">
                    <a href="{$bbsreply.adduser.user_url}"><strong>{$bbsreply.adduser.nickname}</strong></a><span class="lv">LV{$bbsreply.adduser.exp_lv}</span>{$bbsreply.addtime|formatdate}
                  </div>
      
                  <div class="reptxt">{$bbsreply.content}</div>
                </div>
    
                <div class="clear"></div>
              </div>
            </volist>
					
    </div>

  
    
 


    </div>
    <div class="rar">
        <if condition="(C('YTATA_SMS_OPEN') eq '1') OR ($Think.session.ytata.uid Neq '')">
            <a class="btn bbsadd" href="{:RU('bbs/add')}">发表主题</a>
            <else/>
            <a class="btn bbsadd J_user_login" href="javascript:void(0);">发表主题</a>
        </if>

        <div class="tagbox">
            <div class="tit">热门标签</div>
            <div class="more link_gray6"><a href="{:RU('tag/lists')}">更多></a></div>
            <div class="clear"></div>
            <ytata:tag listname="tags" page="0" sort="hot" num="40"/>
            <volist name="tags.list" id="tli">
                <a class="tag" href="{$tli.url}">{$tli.tag}<span>({$tli.count_question})</span></a>
            </volist>
            <div class="clear"></div>
        </div>

      
        <include file="public:rankside" />


    </div>
    <div class="clear"></div>

    </div>

    <script type="text/javascript">
        var uploadUrl = "{:RU('Upload/attach')}";
    </script>
    <include file="public:footer"/>
    <script type="text/javascript">
        // 图片弹出
        function open_img(id) {
            layer.open({
                type: 1,
                title: false,
                closeBtn: 0,
                skin: 'layui-layer-nobg', //没有背景色
                shadeClose: true,
                content: $('#' + id),
                success: function(layero){
                    var imgW = $(layero.selector+' img').width();
                    $(layero.selector).css('left', ($(layero.selector).position().left - (imgW - $(layero.selector).width())/2)+'px');
                    $(layero.selector).width(imgW);
                }
            });
        }

        $(document).ready(function () {
            //追问（补充）表单增加高度
            $('.J_asked_input,.J_supp_input').live('click', function () {
                h = $(this).height();
                if (h == 100) {
                    $(this).animate({height: "22px"}, 500);
                }
                else {
                    $(this).animate({height: "100px"}, 500);
                }
            });

            //主题回复提交
            $(".J_supp_btn").click(function () {
                $(this).attr("disabled", "disabled").addClass('btn_disabled');
                var bid = $(this).data('id');
                var content = $.trim($("textarea[name='content']").val());
                var suppURL = "{:RU('bbs/ajax_bbs_reply_save')}";
                if (content.length == 0) {
                    disapperTooltip("remind", "请填写内容！");
                    $(this).removeAttr("disabled").removeClass('btn_disabled');
                    return false;
                }

                $.getJSON(suppURL, {bid: bid, content: content}, function (json) {
                    console.log(json);
                    if (json.status == 0) {
                        disapperTooltip("remind", json.content);
                        $(this).removeAttr("disabled").removeClass('btn_disabled');
                    } else if (json.status == 1) {
                        disapperTooltip("success", json.content);
                        setTimeout(function () {
                            window.location.reload();
                        }, 1500);
                    } else {
                        disapperTooltip("remind", "未知错误");
                        $(this).removeAttr("disabled").removeClass('btn_disabled');
                    }
                });

            });
            // 主题点赞
            $("#J_bbs_praise").click(function () {
                var praURL = "{:RU('bbs/ajax_inc_praise')}";
                var praise = $(this);
                var bid = praise.data('id');
                $.getJSON(praURL, {bid: bid}, function (json) {
                    console.log(json);
                    if (json.status == 0) {
                        disapperTooltip("remind", json.content);
                    } else if (json.status == 1) {
                        praise.html(json.content);
                        disapperTooltip("success", '感谢你点赞！');
                    } else {
                        disapperTooltip("remind", "未知错误");
                    }
                });

            });
            

            //加关注
            $('.J_follow').live('click', function () {
                var btn = $(this);
                var bid = btn.data('id');
                $.getJSON(ajaxURL, {act: "ajax_bbs_follow", bid: bid}, function (json) {
                    if (json.status == 0) {
                        disapperTooltip("remind", json.content);
                    } else if (json.status == 1) {
                        disapperTooltip("success", json.content);
                        if (btn.text() == '已关注') {
                            btn.text('关注');
                        } else {
                            btn.text('已关注');
                        }
                        $('.J_follow_count').text(json.count);
                    } else {
                        disapperTooltip("remind", "未知错误");
                    }
                });
            });
            //加收藏
            $('.J_favorites').live('click', function () {
                var btn = $(this);
                var bid = btn.data('id');
                var type = '3';
                $.getJSON(ajaxURL, {act: "ajax_favorites", bid: bid, type: type}, function (json) {
                    if (json.status == 0) {
                        disapperTooltip("remind", json.content);
                    } else if (json.status == 1) {
                        disapperTooltip("success", json.content);
                        if (btn.text() == '已收藏') {
                            btn.text('收藏');
                        } else {
                            btn.text('已收藏');
                        }
                        $('.J_favorites_count').text(json.count);
                    } else {
                        disapperTooltip("remind", "未知错误");
                    }
                });
            });
            
            // 主题回复点赞
            $(".J_bbsreply_praise").click(function (e) {
                var $praise = $(this);
                var rid = $praise.data('rid');  // bbsreply_praise_save
                var praURL = "{:RU('bbs/bbsreply_praise_save')}";
                $.getJSON(praURL, {rid: rid}, function (json) {
                    if (json.status == 0) {
                        disapperTooltip("remind", json.content);
                    } else if (json.status == 1) {
                        $praise.html(json.content);
                        disapperTooltip("success", '感谢你点赞！');
                    } else {
                        disapperTooltip("remind", "未知错误");
                    }
                });
            });

        });

        // 图片弹出
        function open_img(id) {
            layer.open({
                type: 1,
                title: false,
                closeBtn: 0,
                skin: 'layui-layer-nobg', //没有背景色
                shadeClose: true,
                content: $('#' + id),
                success: function(layero){
                    var imgW = $(layero.selector+' img').width();
                    $(layero.selector).css('left', ($(layero.selector).position().left - (imgW - $(layero.selector).width())/2)+'px');
                    $(layero.selector).width(imgW);
                }
            });
        }
    </script>
  
    </body>
</html>